﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace SURLService
{
    interface IJob
    {        
        void Run();
    }

    class JobQueue<T> where T : IJob
    {
        private Queue<T> _queue = new Queue<T>();
        private object _queueLock = new object();

        public JobQueue()
        {
        }

        public void Enqueue(T t)
        {
            lock (_queueLock)
            {
                _queue.Enqueue(t);
            }
        }

        public T Dequeue()
        {
            lock (_queueLock)
            {
                return _queue.Dequeue();
            }
        }

        public int Length()
        {
            lock (_queueLock)
            {
                return _queue.Count;
            }
        }
    }
}
